<template>
  <div>
    <ul class="category-ul">
      <li @click="aaa(item.id)" class="item" v-for="item in categoriesList" :key="item.id">
        <img :src="item.image" alt="" />
        <div class="box">
          <div>{{ item.title }}</div>
          <div>{{ dictionary[item.title] }}</div>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import { getCategories } from '@/api/page'
export default {
  data() {
    return {
      categoriesList: [],
      dictionary: {
        公寓: 'APARTMENT',
        商铺: 'SHOP',
        写字楼: 'OFFICE BUILDING',
        住宅: 'DWELLING'
      }
    }
  },
  created() {
    this.getCategories()
  },
  methods: {
    async getCategories() {
      const res = await getCategories()
      this.categoriesList = res.data
      console.log(39, this.categoriesList)
    },
    aaa(id) {
      this.$router.push('list' + '?id=' + id)
    }
  }
}
</script>
<style lang="scss" scoped>
.aaa {
  display: flex;
  justify-content: space-around;
  img {
    flex: 1;
  }
  div {
    flex: 3;
  }
}
.cover {
  width: 100%;
  margin-left: 10px;
}
</style>

<style>
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: '';
}

.clearfix:after {
  clear: both;
}
</style>

<style lang="scss" scoped>
.category-ul {
  // 背景
  background-image: url('@/assets/img/背景图.jpg');
  // background:#F0F2F4;
  // background-color: #6DD5FA;
  background-size: cover;

  margin: 0 0;

  height: 590px;
  padding: 80px 150px 40px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  font-weight: 500;

  .item {
    position: relative;
    list-style: none;
    width: 250px;
    height: 320px;
    background-color: #fff;
    // border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.3);
    // margin-top: 20px;

    // margin-right: 80px;
    img {
      // position: absolute;
      width: 250px;
      height: 250px;
      display: inline-block;
      vertical-align: top;
    }
    .box {
      background-color: #fff;
      height: 70px;
      width: 100%;
      // line-height: 50px;
      // text-align: center;
      display: flex;
      justify-content: center;
      align-items: center;

      flex-direction: column;
    }
    &:nth-child(even) {
      //  background-color: red;
      .box {
        background: #4089d8;
        color: #fff;
      }
    }
    &:nth-child(odd) {
      margin-top: 160px;
      .box {
        position: absolute;
        top: 0;
      }
      img {
        position: absolute;
        top: 70px;
      }
    }
    transition: all 0.5s;
    cursor: pointer;
    &:hover {
      transform: scale(1.1);
    }
  }
}
</style>
